package com.web;

import com.client.NettyTcpClient;
import com.server.NettyTcpServer;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.UnsupportedEncodingException;

/**
 * @program: netty
 * @description:
 * @author: zt22328 赵儒定
 * @create: 2022-11-29 09:47
 **/
@RestController
public class NettyController {

    @Resource
    NettyTcpClient nettyTcpClient;
    @Resource
    NettyTcpServer nettyTcpServer;

    @GetMapping("/client/send")
    public String clientSend(String msg) throws UnsupportedEncodingException, InterruptedException {
        nettyTcpClient.sendMessage(msg);
        return "ok";
    }

    @GetMapping("/server/send")
    public String serverSend(String msg) throws UnsupportedEncodingException, InterruptedException {
        nettyTcpServer.sendMessage(msg);
        return "ok";
    }
}
